package pl.surecase.eu;

import de.greenrobot.daogenerator.DaoGenerator;
import de.greenrobot.daogenerator.Entity;
import de.greenrobot.daogenerator.Schema;

public class MyDaoGenerator {
// 说明文档   http://www.360doc.com/content/14/0513/14/3639038_377234431.shtml

    public static void main(String args[]) throws Exception {
       /* String packName = "com.binvshe.binvshe.message.dao";
        String outDir = args[0];
        int version = 1;
        Schema schema = new Schema(version, packName);

        initMessageTable(schema);
        initUserIconTable(schema);
        new DaoGenerator().generateAll(schema, outDir);*/
        String packageName = args[0];
        String outDir = args[1];

        initMessageSchema(packageName, outDir, 1);
    }


    private static void initMessageSchema(String packName, String outDir, int version) {
        String messagePackageName = packName + ".message.dao";
        Schema schema = new Schema(version, messagePackageName);
        Entity messageTable = schema.addEntity("Message");
//        userBean.addStringProperty("id").primaryKey().index();
        messageTable.addIdProperty();
        messageTable.addStringProperty("icon");
        messageTable.addStringProperty("title");
        messageTable.addStringProperty("content");
        messageTable.addStringProperty("msg_id");
        messageTable.addIntProperty("deletable");
        messageTable.addIntProperty("type");
        messageTable.addStringProperty("date");
        messageTable.addBooleanProperty("isRead");
        messageTable.addStringProperty("extra");

        try {
            new DaoGenerator().generateAll(schema, outDir);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }



    private static void initUserBean(Schema schema) {
        Entity userBean = schema.addEntity("UserBean");
        userBean.setTableName("user");
        userBean.addStringProperty("id").primaryKey().index();
        userBean.addStringProperty("phone");
        userBean.addStringProperty("profile_picture");
        userBean.addStringProperty("client_id");
        userBean.addStringProperty("name");
        userBean.addStringProperty("location");
        userBean.addStringProperty("gender");

    }


    /**
     * @param schema
     */
    private static void initUserTable(Schema schema) {
        Entity userBean = schema.addEntity("User");
        userBean.addStringProperty("userName").primaryKey().index();
        userBean.addStringProperty("avatar");
        userBean.addStringProperty("nickName");
    }

}
